<?php
	
	class m_string{
		

/*------------------------------------------------------------------------------------------------------*/		

		/**
		 * Devuelve el contenido situado entre dos delimitadores.
		 * 
		 * @return string
		 */
		function getContentFromDelimiters($string, $start, $end) {
		    $pos = stripos($string, $start);	
		    $str = substr($string, $pos);	
		    $str_two = substr($str, strlen($start));	
		    $second_pos = stripos($str_two, $end);	
		    $str_three = substr($str_two, 0, $second_pos);
		    $unit = trim($str_three); 
		    return $unit;
		}
/*------------------------------------------------------------------------------------------------------*/	
		
		/**
		* Devuelve la cadena introducida en codigo
		* HTML correspondiete.
		* Usada para filtrar tildes y otros caracteres.
		*
		* @return string
		* @author MadPitbull 
		*/
		
		public function replaceTildes ($cadena){
			$cadena = htmlentities($cadena, ENT_QUOTES | ENT_IGNORE, "UTF-8");
			return $cadena;
		}
/*--------------------------------------------------------------------------------------------------*/
		
		/**
		* Devuelve la cadena introducida en codigoH TML correspondiente - version antigua -.
		* 
		* @return string
		* @author  MadPitbull
		*/
		function replaceTildesOld($cadena){
			$cadena = ereg_replace("á", "&aacute;", $cadena);
			$cadena = ereg_replace("é", "&eacute;", $cadena);
			$cadena = ereg_replace("í", "&iacute;", $cadena);
			$cadena = ereg_replace("ó", "&oacute;", $cadena);
			$cadena = ereg_replace("ú", "&uacute;", $cadena);
			$cadena = ereg_replace("Á", "&Aacute;", $cadena);
			$cadena = ereg_replace("É", "&Eacute;", $cadena);
			$cadena = ereg_replace("Í", "&Iacute;", $cadena);
			$cadena = ereg_replace("Ó", "&Oacute;", $cadena);
			$cadena = ereg_replace("Ú", "&Uacute;", $cadena);
			$cadena = ereg_replace("Ñ", "&Ntilde;", $cadena);
			$cadena = ereg_replace("ñ", "&ntilde;", $cadena);
		
			return $cadena;
		}
		
		
/*--------------------------------------------------------------------------------------------------*/	

		/**
		* Funcion usada para validar un nombre de dominio.
		*
		* @return true o false
		* @author MadPitbull 
		*/
		
		public function validarDominio($dominio)
		{
			//Funcion usada para validar un nombre de dominio
			//Devuelve true si esta bien, en caso contrario devuelve false
			if (preg_match('/^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?/i',
				$dominio)) {
				return true;
			} else {
				return false;
			} //end else if
		} //end validarDominio
			
/*------------------------------------------------------------------------------------------------------*/	
		/*
		* Returns the most repetead words (llonger than $long)
		* given in a string
		*@author MadPitbull
		*/
		function keyWords($txt, $lim, $long = 3) {
			
			$e = explode(" ", str_replace(array(",", "."), " ", strtolower($txt)));
			$a = array_count_values($e);
			arsort($a); array_shift($a);
			$p = array_keys($a);
			for ($l = 0; $l < count($p); $l++) {
				if (strlen($p[$l]) >= $long ) {
					$f[] = $p[$l];
				}
			}
			for ($i = 0; $i < $lim; $i++) {
				$kW[] = $f[$i];
			}
			return $kW;
		}
/*------------------------------------------------------------------------------------------------------*/	
		
		
		
		
	}//End class string
?>